#!/bin/bash

# Depending on where PyBlosxom is, you might have to call this script
# like this:
#
#    PYTHONPATH=xyz ./compile.sh
#
# where "xyz" is the directory to PyBlosxom.

set -o errexit

if [[ -d ./logs/ ]]
then
    echo ">>> logs directory exists."
else
    echo ">>> logs directory doesn't exist--creating."
    mkdir ./logs/
fi

if [[ -d ./compiled_site/ ]]
then
    echo ">>> compiled_site exists, removing it...."
    rm -rf ./compiled_site/
fi

echo ">>> creating compiled_site directory...."
mkdir ./compiled_site/

cd site
echo ">>> compiling site...."
python ./pyblosxom.cgi staticrender

echo ">>> copying over static files...."
cp -arv static/* ../compiled_site/

echo ">>> copying over htaccess..."
cd ..
cp -arv htaccess compiled_site/.htaccess
